home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / ZegsRule / Read Me < prev    next >
Text File  |  2000-04-28  |  6KB  |  67 lines

  1. ZegsRuler
  2.  
  3. ©2000 Peter Zegelin - All rights reserved
  4.  
  5. http://zegsoft.tripod.com/realbasic.html
  6.  
  7. email: zegsoft@kagi.com
  8. or:                                 zegelin@actonline.com.au
  9.  
  10. Current version: 0.6b  April 2000
  11.  
  12. Overview
  13.  
  14.             ZegsRuler is a set of classes that enable you to add all sorts of rulers and scales to your project *really* easily. ZegsRuler supports scaling (zooming),scrolling and changing of the origin as well almost complete control over line length, color, background, text etc. In addition,all rulers can be either plain or 3D. The package consists of a ZegsRuler class and some supporting classes as well as a few sub classes that provide higher level access to the ZegsRuler class. In many cases the ruler types found in one of the subclasses will be all that you need. For instance, the GraphicsRuler provides inch (8,10,12 divisions) and cm (10) rulers that scale from 3% to 3200% and can easily be extended if required. A TabRuler subclass extends this to provide some support for tabs (coming soon). A few scale type classes show how you can easily set up a scale for sliders etc.
  15.             This class only uses RB code so it works on 68K macs but is rather slow. I havent tried it in windoze but it should work. Also, please note that ZegRuler uses 16 bit pictures internally to rotate the text using the RGBSurface property and will therefore only work on alphas > a27 or 2.1
  16.  
  17.     ZegsRuler is shareware - $15US (or will be when it is finalised) and will be available for purchase via Kagi. At the moment it not possible to register it so it will only work for 5 minutes or so before not redrawing itself.
  18.  
  19. Basic Usage - Graphics Ruler
  20.  
  21.             After dragging ZegsRuler and its support classes (lineData,textdata) and the GraphicsRuler subclass to your project either create a new canvas and make its superclass GraphicsRuler or just drag an instance of GraphicsRuler onto your window. Make the canvas long and narrow like a real ruler. Give the ruler(canvas) a name such as "topRuler".
  22.  
  23. Initialisation - Before your ruler will draw anything you have to initialise it. To do this call Initialize() followed by Reset(). For a full description of these two methods see later but for now calling topRuler.Initialize("",1)  followed by topRuler.Reset(2,3,1) in the windows Open event, will give you a pretty standard 1 inch ruler with 10th inch markings. Run your project and you should get a ruler! If you lock the top, left and right of the canvas it will even resize. If you run the cursor over the ruler it will track the mouse. OK its not much but then again it only took a minute! If you want to make a vertical ruler resize your canvas (tall and narrow), change the 1 in topRuler.Initialize to a 4 and run again!
  24.  
  25. Main Methods
  26.  
  27. Initialize(registration as String,side as integer)
  28.     This should be called first to register the class and set up a few variables that are unlikely to change such as the font, side, colors and whether or not the frame is drawn. An unregistered ruler will only work for about 5 minutes before refusing to redraw.
  29. registration - your 12 digit registration code. If experimenting just use "".
  30. side - 1 - top, 2 - right, 3 - bottom, 4 - left. Determines which side the text and ruler marks will appear
  31.  
  32.  
  33. Reset(rulerType as integer,textLocation as integer,scale as double)
  34. This is the main routine used to change the ruler. In all cases sending 0 as a parameter uses the current value for that parameter, so this method is used to change any or all of these settings. For instance to change your ruler to centimeters just call topRuler.Reset(1,0,0).
  35. rulerType - may be 1 - cm10, 2 - inch10, 3 - inch12,4 - inch16   etc. You can add your own types or modify the existing types and delete types that you dont want.
  36. textLocation -  for horizontal rulers -1 left of mark,2 centered over mark, 3 right of mark. For vertical rulers 1 above mark, 2 centered, 3 below mark. The text will be rotated to read up. If you dont want the text rotated then add 10 to the value (ie 11,12,13). The unrotated text and text centered over the mark only works well with wider rulers .
  37. scale - any value from .03 to 32 can be used. 1 specifies 100%. Smaller numbers represent smaller scales, larger numbers represent larger scales. eg .5 is half scale, 2 is double scale. You can extend these if you like. See Customization.
  38.  
  39.  
  40. MousePosition(x as integer,y as integer,dotted as boolean,lineColor as Color) - this is used to update the mouse marker on the ruler. Only the x value is used on horizontal rulers so y can be set to 0. Vertical rulers only use the y value so x can be set to 0. To hide the marker the corresponding value can be set to anything less than 0.
  41. dotted  - will draw a dotted line if set to true. 
  42. lineColor - the mouse marker will be drawn in the color passed in here
  43.  
  44.  
  45. Properties you have to set:
  46.  
  47. scale(double) -    Can be virtually anything but 0
  48. drawFrame(Boolean) - Draws the frame in the frameColor if set to true
  49. side(Integer) - from 1 to 4. Runs clockwise from the top. A top ruler will draw its minor marks at the bottom of the ruler!
  50. is3D(Boolean) - set to true if you want a 3D look. If set you should also set the color3D to the color you want
  51. textLocation(Integer) - 1,2 or 3 for horizontal and vertical(rotated). 11,12,13 for vertical unrotated
  52.  
  53. frameColor(Color) - color of the frame, if drawFrame is set to true
  54. backColor(Color) - any color you like. If you dont set it it will be black and if your text is also black...
  55. color3D(Color) - color that the 3D marks will be drawn in
  56.  
  57. Origin and Offset - The origin is where the zero mark is drawn and is usually changed via a canvas situated between a horizontal and vertical ruler. See the project for an example. Offset is affected by the scrollbars. See project for example.
  58.  
  59.  
  60. Disclaimer
  61.             Although all efforts have been made to ensure the quality and the accuracy of ZegsRuler, the author assumes no responsibility for direct, indirect, special, incidental or consequential damages resulting from any errors contained in the manuals or in the program, even if advised of the possibility of such damages.
  62.  
  63. Version History
  64.  
  65. 0.6 b - April 2000 Initial Release
  66.  
  67.